Install Miniconda from their Website.
All required python packages will be downloaded using the conda
package and environment management system.
When Miniconda is installed on your system, open up your shell with the command WINDOWS + R -> cmd
on windows or search for the
terminal
on Linux systems.
Then type this to make sure you got the latest version.
In [ ]:
conda update --all
A new environment capsule with preset libraries installed for one or more of your projects can be created. fauenv
is the name of the new python 3.x environment in this example.
In [ ]:
conda create -n fauenv python=3
Check which environments are currently installed. root
is the name of the default one.
In [ ]:
conda info -e
Then, activate
the desired environment.
In [ ]:
activate fauenv
With this command, all required packages as well as their dependencies will be installed in the latest version possible. Version conflicts between them are avoided automatically.
Note, those packages are only installed for the chosen environment.
If you want to install them on another environment in the same version,conda
automatically creates the hardlinks to the library's directory, avoiding to have numerous copies of the same library on the filesystem.
Use conda to install new packages.
In [ ]:
conda install -n fauenv numpy scipy matplotlib scikit-learn scikit-image ipython ipython-notebook
conda install -n fauenv nose pip anaconda-client pillow ujson flask jinja2 natsort joblib numba pyside
Install packages not in the conda repository via pip.
In [ ]:
activate fauenv # if not in fauenv environment already
pip install visvis tinydb nibabel pydicom medpy simpleITK pycuda numpy-stl websockets
In [ ]:
conda clean -tps # delete downloaded cached tarballs (t), orphaned packages (p), and cached sources (s)
In [ ]:
conda update --all -n fauenv
activate fauenv # if not in fauenv environment already
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
Now, all is set up to get started.
The Jupyter Notebook is a web-based interactive computational environment to combine code execution, text, mathematics, plots and rich media into a single document.
Jupyter stands for Julia, Python and R, which are the main proramming languages supported.
There are several tutorials for this framework.
To start Jupyter Notebook call
In [ ]:
jupyter notebook # --port 8888
The console will show an URL like http://localhost:8888/tree and open the operating system's default browser with this location.
Use it to navigate, open, create, delete, and run .ipynb
files.
Note: For inline plots use this magic function at the beginning of your code. This also imports numpy as np
, imports matplotlib.pyplot as plt
, and others.
In [ ]:
%pylab inline
In [1]:
%time sum(range(int(1e7)))
Out[1]:
In [2]:
%timeit sum(range(10000000))
In standard python this would be achieved by
In [ ]:
python -mtimeit -s"import test" "mytestFunction(42)"
Some useful magic functions are
%time
or %timeit
for benchmarks%prun
for profiling%magic
returns a list of all magic functions%load
or %loadpy
to import a .py
file into the notebook%quickref
for a reference sheet
In [ ]:
%quickref
There are some great websites where ready-made Jupyter Notebook files can be found and imported:
.ipynb
render engine for notebooks on github
In [ ]:
conda update --all
conda update --all -n fauenv
activate fauenv
conda clean -tps
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
jupyter notebook
Upgrading to a new version of python
In [ ]:
activate fauenv
conda install python=3.6
Download the IDE here: jetbrains.com
In PyCharm go to
C:\Miniconda3\envs\fauenv\python.exe
, where fauenv is the environment you want to use